<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@ page language="java" import="java.util.*,java.text.*" %>
<%@ page language="java" import="org.wiki.excel.core.ExcelUtil" %>
<%@ page language="java" import="org.wiki.excel.entity.Record" %>
<%@ page language="java" import="java.io.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<%
	String print = "";
	String name = "";
	String title = "";
	String remark ="";
	String printTime ="";
	if(request.getParameter("Print")!=null
	||request.getParameter("PrintName")!=null
	||request.getParameter("title")!=null
	||request.getParameter("remark")!=null
	||request.getParameter("printTime")!=null	){
		print = (String)request.getParameter("Print");
		name = (String)request.getParameter("PrintName");
		remark = (String)request.getParameter("printRemark");
		printTime = (String)request.getParameter("printTime");
		//title = (String)request.getParameter("title");
		//System.out.println("标题为："+title);
	
		print = print.replace("\r","");
		print = print.replace("\n","");
		System.out.println("打印的值:"+print);
		String[] printll = print.split("@!");
		System.out.println("字符串的长度为："+printll.length);
		List<Record> recordList = new ArrayList<Record>();
		
		String[] record0 ={"","","","","名称：",name};
		String[] record1 ={"节数/星期","星期一","星期二","星期三","星期四","星期五"};
		String[] record2 ={"一二节",printll[0],printll[1],printll[2],printll[3],printll[4]};
		String[] record3 ={"三四节",printll[5],printll[6],printll[7],printll[8],printll[9]};
		String[] record4 ={"五六节",printll[10],printll[11],printll[12],printll[13],printll[14]};
		String[] record5 ={"七节"  ,printll[15],printll[16],printll[17],printll[18],printll[19]};
		String[] record6 ={remark  ,"","","",printTime,""};
		
		recordList.add(new Record(0,record0));
		recordList.add(new Record(1,record1));
		recordList.add(new Record(2,record2));
		recordList.add(new Record(3,record3));
		recordList.add(new Record(4,record4));
		recordList.add(new Record(5,record5));
		recordList.add(new Record(6,record6));
		
		//Excel标题列名
		String[] fieldName = {"","",title,"","",""};
		boolean[] isDisplay = {true,true,true,true,true,true};
		int[] columnView ={10,30,30,30,30,30};
		DateFormat df = new SimpleDateFormat("yyyyMMddhh"); 
		String url = "C:/Users/Administrator/Desktop/schedule/WebRoot/temp/"+df.format(new Date())+"_"+name+"课表.xls";
		System.out.println("文件的路径："+url);
		ExcelUtil.exoprtToExcel(url, recordList, fieldName,isDisplay,columnView);

		System.out.println("导出成功...");
		
		//String filePath = request.getParameter("file");
		//System.out.println("FilePath1:"+filePath);
		/**File file = new File(url);
		InputStream fi = new FileInputStream(file);
		System.out.println("文件名为："+file.getName());
		response.setHeader("Content-Disposition","attachment; filename="+file.getName());
    	OutputStream outOS=response.getOutputStream();
    	BufferedOutputStream bos=new BufferedOutputStream(outOS);
		byte[] bt = new byte[4096];
		int i=-1;
		
		while((i=fi.read(bt))>=0)
		{
			bos.write(bt,0,i);
		}
		
		bos.flush();
		fi.close();
		bos.close();
		*/
		
		//response.reset();
		//outOS.clear();
		//
		%>
		<script type="text/javascript" >
		
			alert("导出成功!");
			window.close();
			
		</script>
	<%
	}else{
	%>
		<script type="text/javascript" >
			alert("导出异常，请联系管理员!");
			window.close();
			<%}
			out.clear();
		out=pageContext.pushBody();
			%>
		</script>

</body>
</html>